/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package co.com.smart.hawk.view.impl;

import co.com.smart.hawk.controller.HawkCiudadesCtrl;
import co.com.smart.hawk.controller.HawkDatosMaestrosCtrl;
import co.com.smart.hawk.controller.HawkDepartamentosCtrl;
import co.com.smart.hawk.controller.HawkTercerosCtrl;
import co.com.smart.hawk.dto.*;
import co.com.smart.hawk.utilities.*;
import co.com.smart.hawk.view.HawkTercerosView;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import javax.swing.*;
import javax.swing.event.InternalFrameAdapter;
import javax.swing.event.InternalFrameEvent;
import java.text.DateFormat;
import java.text.SimpleDateFormat;


/**
 *
 * @author User
 */
public final class HawkClienteProveedorViewImpl extends javax.swing.JInternalFrame implements HawkTercerosView{
    
    private HawkTercerosCtrl controller;
    private HawkDatosMaestrosCtrl controllerDatosMaestros;
    private HawkDepartamentosCtrl controllerDepartamentos;
    private HawkCiudadesCtrl controllerCiudades;
    private HawkComboBoxMgr<DepartamentoDTO> comboMgrDepartamento;
    private HawkCiudadesCtrl HawkCiudadesCtrl;
    private HawkComboBoxMgr<CiudadDTO> comboMgrCiudad;
    private HawkComboBoxMgr<DatosMaestrosDTO> comboMgrTipoDocumento;
    private HawkTextFieldMgr textMgr;
    
    
    /**
     * Creates new form HawkClienteProveedorViewImpl
     */
    public HawkClienteProveedorViewImpl(JDesktopPane desktopPane, HawkTercerosCtrl hawkTercerosCtrl, HawkDatosMaestrosCtrl hawkDatosMaestrosCtrl, HawkDepartamentosCtrl hawkDepartamentosCtrl,HawkCiudadesCtrl hawkCiudadesCtrl ) {
        if (HawkViewMgr.getInstance().getObjectInstance(this.getClass()) == null) {
            try {
                this.controller = hawkTercerosCtrl;
                this.controllerDatosMaestros = hawkDatosMaestrosCtrl;
                this.controllerDepartamentos = hawkDepartamentosCtrl;
                this.controllerCiudades = hawkCiudadesCtrl;
                textMgr = new HawkTextFieldMgr();
                initComponents();
                this.initEvent();
                this.initComponentsTerceros();
                //this.consultarArticulos();
                java.awt.Dimension dimension = desktopPane.size();
                java.awt.Dimension ventan = this.getSize();
                this.setLocation(new java.awt.Point((dimension.width - ventan.width) / 1, (dimension.height - ventan.height) / 1));
                HawkViewMgr.getInstance().setObjectInstance(this);
            } catch (Throwable ex) {
                ex.printStackTrace();
            }
        
    }
    
    
 
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        bindingGroup = new org.jdesktop.beansbinding.BindingGroup();

        jPanel1 = new javax.swing.JPanel();
        jPanel2 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        btnlimpiar = new javax.swing.JButton();
        jPanel3 = new javax.swing.JPanel();
        jPanel5 = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        cbTipoDocumento = new javax.swing.JComboBox();
        jLabel3 = new javax.swing.JLabel();
        txtcoidentificacion = new javax.swing.JTextField();
        jpNatural = new javax.swing.JPanel();
        jLabel4 = new javax.swing.JLabel();
        txtDsprimernombre = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        txtDssegundonombre = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        txtDsprimerapellido = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        txtDssegundoapellido = new javax.swing.JTextField();
        jpJuridico = new javax.swing.JPanel();
        jLabel8 = new javax.swing.JLabel();
        txtDsrazonsocial = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        txtDsnombrecontacto = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();
        txtDscelular = new javax.swing.JTextField();
        jLabel11 = new javax.swing.JLabel();
        txtDsextension = new javax.swing.JTextField();
        jLabel12 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        txtDstelefono = new javax.swing.JTextField();
        txtDsemail = new javax.swing.JTextField();
        cbDepartamento = new javax.swing.JComboBox();
        cbCiudad = new javax.swing.JComboBox();
        txtDsdireccion = new javax.swing.JTextField();
        jLabel17 = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();
        jdFechaNacimiento = new com.toedter.calendar.JDateChooser();

        setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
        setTitle("SmartHawk-Cliente Proveedor");
        setAutoscrolls(true);
        setFrameIcon(new javax.swing.ImageIcon(getClass().getResource("/img/smart-jungle.png"))); // NOI18N

        org.jdesktop.beansbinding.Binding binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, jScrollPane1, org.jdesktop.beansbinding.ObjectProperty.create(), this, org.jdesktop.beansbinding.BeanProperty.create("autoscrolls"));
        bindingGroup.addBinding(binding);

        jPanel1.setBackground(new java.awt.Color(255, 255, 255));
        jPanel1.setAutoscrolls(true);

        jLabel1.setFont(new java.awt.Font("Verdana", 1, 12));
        jLabel1.setText("Cliente Proveedor");

        jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/guardar.png"))); // NOI18N
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jButton3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/consultar.png"))); // NOI18N

        btnlimpiar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/limpiar.png"))); // NOI18N
        btnlimpiar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnlimpiarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 412, Short.MAX_VALUE)
                .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 48, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(btnlimpiar, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(24, 24, 24))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabel1))
                    .addComponent(jButton1)
                    .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnlimpiar, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jLabel2.setText("Tipo Documento  *");

        cbTipoDocumento.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cbTipoDocumentoActionPerformed(evt);
            }
        });

        jLabel3.setText("Número *");

        txtcoidentificacion.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtcoidentificacionActionPerformed(evt);
            }
        });
        txtcoidentificacion.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                txtcoidentificacionKeyPressed(evt);
            }
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txtcoidentificacionKeyTyped(evt);
            }
        });

        jpNatural.setBorder(javax.swing.BorderFactory.createTitledBorder(""));

        jLabel4.setText("Primer Nombre *");

        txtDsprimernombre.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtDsprimernombreActionPerformed(evt);
            }
        });
        txtDsprimernombre.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txtDsprimernombreKeyTyped(evt);
            }
        });

        jLabel5.setText("Segundo Nombre");

        txtDssegundonombre.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txtDssegundonombreKeyTyped(evt);
            }
        });

        jLabel6.setText("Primer Apellido *");

        txtDsprimerapellido.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txtDsprimerapellidoKeyTyped(evt);
            }
        });

        jLabel7.setText("Segundo Apellido *");

        txtDssegundoapellido.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txtDssegundoapellidoKeyTyped(evt);
            }
        });

        javax.swing.GroupLayout jpNaturalLayout = new javax.swing.GroupLayout(jpNatural);
        jpNatural.setLayout(jpNaturalLayout);
        jpNaturalLayout.setHorizontalGroup(
            jpNaturalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jpNaturalLayout.createSequentialGroup()
                .addGroup(jpNaturalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addComponent(jLabel6)
                    .addComponent(jLabel4))
                        .addGap(18, 18, 18)
                .addGroup(jpNaturalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jpNaturalLayout.createSequentialGroup()
                        .addComponent(txtDsprimernombre, javax.swing.GroupLayout.PREFERRED_SIZE, 226, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(37, 37, 37)
                        .addComponent(jLabel5))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jpNaturalLayout.createSequentialGroup()
                        .addComponent(txtDsprimerapellido, javax.swing.GroupLayout.PREFERRED_SIZE, 226, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jLabel7)))
                        .addGap(18, 18, 18)
                .addGroup(jpNaturalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(txtDssegundoapellido, javax.swing.GroupLayout.DEFAULT_SIZE, 214, Short.MAX_VALUE)
                    .addComponent(txtDssegundonombre))
                .addContainerGap(39, Short.MAX_VALUE))
        );
        jpNaturalLayout.setVerticalGroup(
            jpNaturalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jpNaturalLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jpNaturalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(txtDsprimernombre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel5)
                    .addComponent(txtDssegundonombre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jpNaturalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6)
                    .addComponent(txtDsprimerapellido, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(txtDssegundoapellido, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        jpJuridico.setBorder(javax.swing.BorderFactory.createTitledBorder(""));

        jLabel8.setText("Razón Social *");

        txtDsrazonsocial.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txtDsrazonsocialKeyTyped(evt);
            }
        });

        jLabel9.setText("Nombre Contacto *");

        txtDsnombrecontacto.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtDsnombrecontactoActionPerformed(evt);
            }
        });
        txtDsnombrecontacto.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txtDsnombrecontactoKeyTyped(evt);
            }
        });

        javax.swing.GroupLayout jpJuridicoLayout = new javax.swing.GroupLayout(jpJuridico);
        jpJuridico.setLayout(jpJuridicoLayout);
        jpJuridicoLayout.setHorizontalGroup(
            jpJuridicoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jpJuridicoLayout.createSequentialGroup()
                .addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(txtDsrazonsocial, javax.swing.GroupLayout.PREFERRED_SIZE, 218, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(29, 29, 29)
                .addComponent(jLabel9)
                .addGap(18, 18, 18)
                .addComponent(txtDsnombrecontacto, javax.swing.GroupLayout.PREFERRED_SIZE, 208, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(50, Short.MAX_VALUE))
        );
        jpJuridicoLayout.setVerticalGroup(
            jpJuridicoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jpJuridicoLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jpJuridicoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtDsrazonsocial, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel8)
                    .addComponent(jLabel9)
                    .addComponent(txtDsnombrecontacto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jLabel10.setText("Teléfono Fijo *");

        txtDscelular.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txtDscelularKeyTyped(evt);
            }
        });

        jLabel11.setText("Extensión");

        txtDsextension.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtDsextensionActionPerformed(evt);
            }
        });
        txtDsextension.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txtDsextensionKeyTyped(evt);
            }
        });

        jLabel12.setText("Celular *");

        jLabel13.setText("Email");

        jLabel14.setText("Dirección");

        jLabel15.setText("Departamento *");

        txtDstelefono.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txtDstelefonoKeyTyped(evt);
            }
        });

        txtDsemail.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txtDsemailKeyTyped(evt);
            }
        });

        cbDepartamento.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cbDepartamentoActionPerformed(evt);
            }
        });

        txtDsdireccion.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txtDsdireccionKeyTyped(evt);
            }
        });

        jLabel17.setText("Ciudad *");

        jLabel16.setText("Fecha nacimiento:");

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jpNatural, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(jpJuridico, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addComponent(jLabel14)
                .addGap(18, 18, 18)
                .addComponent(txtDsdireccion, javax.swing.GroupLayout.PREFERRED_SIZE, 260, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 396, Short.MAX_VALUE))
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel5Layout.createSequentialGroup()
                        .addContainerGap()
                                .addComponent(jLabel2)
                                .addGap(18, 18, 18)
                        .addComponent(cbTipoDocumento, javax.swing.GroupLayout.PREFERRED_SIZE, 96, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(65, 65, 65)
                                .addComponent(jLabel3)
                        .addGap(18, 18, 18)
                        .addComponent(txtcoidentificacion, javax.swing.GroupLayout.PREFERRED_SIZE, 295, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanel5Layout.createSequentialGroup()
                                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel11)
                                    .addComponent(jLabel12)
                            .addComponent(jLabel17))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel5Layout.createSequentialGroup()
                                .addComponent(txtDscelular, javax.swing.GroupLayout.PREFERRED_SIZE, 256, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(29, 29, 29)
                                .addComponent(jLabel10))
                            .addGroup(jPanel5Layout.createSequentialGroup()
                                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(txtDsextension)
                                    .addComponent(cbCiudad, 0, 256, Short.MAX_VALUE))
                                .addGap(29, 29, 29)
                                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(jLabel15, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jLabel13)
                                    .addComponent(jLabel16, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
                        .addGap(21, 21, 21)
                        .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jdFechaNacimiento, javax.swing.GroupLayout.DEFAULT_SIZE, 214, Short.MAX_VALUE)
                            .addComponent(txtDstelefono, javax.swing.GroupLayout.DEFAULT_SIZE, 214, Short.MAX_VALUE)
                            .addComponent(cbDepartamento, 0, 214, Short.MAX_VALUE)
                            .addComponent(txtDsemail, javax.swing.GroupLayout.DEFAULT_SIZE, 214, Short.MAX_VALUE))))
                .addGap(45, 45, 45))
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(cbTipoDocumento, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel3)
                    .addComponent(txtcoidentificacion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jpNatural, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jpJuridico, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel12, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(txtDscelular, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel10)
                    .addComponent(txtDstelefono, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel11)
                    .addComponent(txtDsextension, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel15)
                    .addComponent(cbDepartamento, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(cbCiudad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel17)
                    .addComponent(jLabel13)
                    .addComponent(txtDsemail, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel14)
                        .addComponent(txtDsdireccion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel16))
                    .addComponent(jdFechaNacimiento, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(64, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 0, Short.MAX_VALUE))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 0, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, 366, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(23, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(766, 766, 766))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 39, Short.MAX_VALUE))
        );

        bindingGroup.bind();

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed

        grabarTerceros();
    }//GEN-LAST:event_jButton1ActionPerformed

    private void txtDsprimernombreActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtDsprimernombreActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_txtDsprimernombreActionPerformed

    private void txtDsnombrecontactoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtDsnombrecontactoActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_txtDsnombrecontactoActionPerformed

    private void txtDsextensionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtDsextensionActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_txtDsextensionActionPerformed

    private void btnlimpiarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnlimpiarActionPerformed
        limpiarFormulario();
    }//GEN-LAST:event_btnlimpiarActionPerformed

    private void cbTipoDocumentoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbTipoDocumentoActionPerformed
        // TODO add your handling code here:
        ocultarcomponente();
    }//GEN-LAST:event_cbTipoDocumentoActionPerformed

    private void cbDepartamentoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbDepartamentoActionPerformed
        // TlisODO add your handling code here:
        listarCiudades();
    }//GEN-LAST:event_cbDepartamentoActionPerformed

    private void txtcoidentificacionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtcoidentificacionActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_txtcoidentificacionActionPerformed

    private void txtcoidentificacionKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtcoidentificacionKeyTyped
        // TODO add your handling code here:
        textMgr.validarNumericos(evt, txtcoidentificacion, 15);
    }//GEN-LAST:event_txtcoidentificacionKeyTyped

    private void txtDscelularKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtDscelularKeyTyped
        // TODO add your handling code here:
        textMgr.validarNumericos(evt, txtDscelular, 15);
    }//GEN-LAST:event_txtDscelularKeyTyped

    private void txtDstelefonoKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtDstelefonoKeyTyped
        // TODO add your handling code here:
        textMgr.validarNumericos(evt, txtDstelefono, 10);
    }//GEN-LAST:event_txtDstelefonoKeyTyped

    private void txtDsextensionKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtDsextensionKeyTyped
        // TODO add your handling code here:
        textMgr.validarNumericos(evt, txtDsextension, 7);
    }//GEN-LAST:event_txtDsextensionKeyTyped

    private void txtDsprimernombreKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtDsprimernombreKeyTyped
        // TODO add your handling code here:
        textMgr.validarTamano(evt, txtDsprimernombre, 150);
        
    }//GEN-LAST:event_txtDsprimernombreKeyTyped

    private void txtDssegundonombreKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtDssegundonombreKeyTyped
        // TODO add your handling code here:
        textMgr.validarTamano(evt, txtDssegundonombre, 50);
        
        
    }//GEN-LAST:event_txtDssegundonombreKeyTyped

    private void txtDsprimerapellidoKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtDsprimerapellidoKeyTyped
        // TODO add your handling code here:
        textMgr.validarTamano(evt, txtDsprimerapellido, 50);
    }//GEN-LAST:event_txtDsprimerapellidoKeyTyped

    private void txtDssegundoapellidoKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtDssegundoapellidoKeyTyped
        // TODO add your handling code here:
        
        textMgr.validarTamano(evt, txtDssegundoapellido, 50);
    }//GEN-LAST:event_txtDssegundoapellidoKeyTyped

    private void txtDsrazonsocialKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtDsrazonsocialKeyTyped
        // TODO add your handling code here:
        textMgr.validarTamano(evt, txtDsrazonsocial, 150);
    }//GEN-LAST:event_txtDsrazonsocialKeyTyped

    private void txtDsnombrecontactoKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtDsnombrecontactoKeyTyped
        // TODO add your handling code here:
        textMgr.validarTamano(evt, txtDsnombrecontacto, 150);
    }//GEN-LAST:event_txtDsnombrecontactoKeyTyped

    private void txtDsdireccionKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtDsdireccionKeyTyped
        // TODO add your handling code here:
        textMgr.validarTamano(evt, txtDsdireccion, 150);
    }//GEN-LAST:event_txtDsdireccionKeyTyped

    private void txtDsemailKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtDsemailKeyTyped
        // TODO add your handling code here:
        textMgr.validarTamano(evt, txtDsemail, 150);
    }//GEN-LAST:event_txtDsemailKeyTyped

    private void txtcoidentificacionKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtcoidentificacionKeyPressed
        // TODO add your handling code here:
        
    }//GEN-LAST:event_txtcoidentificacionKeyPressed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnlimpiar;
    private javax.swing.JComboBox cbCiudad;
    private javax.swing.JComboBox cbDepartamento;
    private javax.swing.JComboBox cbTipoDocumento;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JComboBox jComboBox2;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel5;
    private com.toedter.calendar.JDateChooser jdFechaNacimiento;
    private javax.swing.JPanel jpJuridico;
    private javax.swing.JPanel jpNatural;
    private javax.swing.JTextField txtDscelular;
    private javax.swing.JTextField txtDsdireccion;
    private javax.swing.JTextField txtDsemail;
    private javax.swing.JTextField txtDsextension;
    private javax.swing.JTextField txtDsnombrecontacto;
    private javax.swing.JTextField txtDsprimerapellido;
    private javax.swing.JTextField txtDsprimernombre;
    private javax.swing.JTextField txtDsrazonsocial;
    private javax.swing.JTextField txtDssegundoapellido;
    private javax.swing.JTextField txtDssegundonombre;
    private javax.swing.JTextField txtDstelefono;
    private javax.swing.JTextField txtcoidentificacion;
    private org.jdesktop.beansbinding.BindingGroup bindingGroup;
    // End of variables declaration//GEN-END:variables

    @Override
    public void initEvent() {
         this.addInternalFrameListener(new InternalFrameAdapter() {

            @Override
            public void internalFrameClosing(InternalFrameEvent e) {
                SwingWorker<Void, Void> worker = new SwingWorker<Void, Void>() {

                    @Override
                    protected Void doInBackground() throws Exception {
                        return null;
                    }

                    @Override
                    protected void done() {
                        cancelarProceso();
                    }
                };
                worker.execute();
            }
        });
    }

    @Override
    public void grabarTerceros() {
         if (ValidarCampos()) {
            try {
                TerceroDTO sendObject = new TerceroDTO();
                DatosMaestrosDTO tipodoc = comboMgrTipoDocumento.getSelectedItem();
                CiudadDTO cbciudad = comboMgrCiudad.getSelectedItem();
                DatosMaestrosDTO tipoter=new DatosMaestrosDTO();
                tipoter.setScdatmaestro(new BigDecimal(14));
                
                
                sendObject.setTipodocumento(tipodoc);                
                sendObject.setCoidentificacion(txtcoidentificacion.getText());
                sendObject.setTipotercero(tipoter);/*revisar el guardar tipo tercero*/
                sendObject.setDsprimernombre(txtDsprimernombre.getText());
                sendObject.setDssegundonombre(txtDssegundonombre.getText());
                sendObject.setDsprimerapell(txtDsprimerapellido.getText());
                sendObject.setDssegundoapell(txtDssegundoapellido.getText());
                sendObject.setDsrazonsocial(txtDsrazonsocial.getText());
                sendObject.setDsnombrecont(txtDsnombrecontacto.getText());
                sendObject.setCotelefono(txtDstelefono.getText());
                sendObject.setDsextension(txtDsextension.getText());
                sendObject.setDscelular(txtDscelular.getText());
                sendObject.setDsemail(txtDsemail.getText());
                sendObject.setDsdireccion(txtDsdireccion.getText());
                sendObject.setCiudad(cbciudad); 
                DateFormat df = new SimpleDateFormat(jdFechaNacimiento.getDateFormatString());
                sendObject.setFhnacimiento(df.format(jdFechaNacimiento.getDateEditor().getDate()));
                
                jdFechaNacimiento.getDateEditor().setDate(df.parse("<fecha>"));             

                controller.grabarTercero(new Utility.CallBackSmartHawk<TerceroDTO>() {

                    @Override
                    public void endProcess(TerceroDTO object) {
                         JOptionPane.showMessageDialog(HawkClienteProveedorViewImpl.this, object.getDsmensaje(), "Información", JOptionPane.INFORMATION_MESSAGE);
                        limpiarFormulario();
    }
                }, sendObject);


            } catch (Throwable thr) {
                JOptionPane.showMessageDialog(this, "Error almacenado el cliente proveedor: \n" + thr.getMessage(), "Error procesando", JOptionPane.ERROR_MESSAGE);
                return;
            }

        }
        
    }
    
    private boolean ValidarCampos (){
        
        boolean flag = true; 
        
        if (this.comboMgrTipoDocumento.getSelectedItem() == null && flag) {
            JOptionPane.showMessageDialog(this, "El tipo de Documento es obligatoria", "Validación", JOptionPane.WARNING_MESSAGE);
            flag = false;
        }
         if (txtcoidentificacion == null || "".equals(txtcoidentificacion.getText()) && flag) {
            JOptionPane.showMessageDialog(this, "El número de identificación es obligatorio", "Validación", JOptionPane.WARNING_MESSAGE);
            flag = false;
            txtcoidentificacion.grabFocus();
        }
        if("nit".equals(this.comboMgrTipoDocumento.getSelectedItem().getDsdatmaestro() )){
            if (txtDsrazonsocial == null || "".equals(txtDsrazonsocial.getText()) && flag) {
                    JOptionPane.showMessageDialog(this, "La razón social es obligatorio", "Validación", JOptionPane.WARNING_MESSAGE);
                    flag = false;
                    txtDsrazonsocial.grabFocus();
                }
                if (txtDsnombrecontacto == null || "".equals(txtDsnombrecontacto.getText()) && flag) {
                    JOptionPane.showMessageDialog(this, "El nombre del contacto es obligatorio", "Validación", JOptionPane.WARNING_MESSAGE);
                    flag = false;
                    txtDsnombrecontacto.grabFocus();
                } 
        }
         if("cc".equals(this.comboMgrTipoDocumento.getSelectedItem().getDsdatmaestro())){
              if (txtDsprimernombre == null || "".equals(txtDsprimernombre.getText()) && flag) {
                    JOptionPane.showMessageDialog(this, "El primer nombre es obligatorio", "Validación", JOptionPane.WARNING_MESSAGE);
                    flag = false;
                    txtDsprimernombre.grabFocus();
                }

                  if (txtDsprimerapellido == null || "".equals(txtDsprimerapellido.getText()) && flag) {
                    JOptionPane.showMessageDialog(this, "El primer apellido es obligatorio", "Validación", JOptionPane.WARNING_MESSAGE);
                    flag = false;
                    txtDsprimerapellido.grabFocus();
                }
                if (txtDssegundoapellido == null || "".equals(txtDssegundoapellido.getText()) && flag) {
                    JOptionPane.showMessageDialog(this, "El segúndo apellido es obligatorio", "Validación", JOptionPane.WARNING_MESSAGE);
                    flag = false;
                    txtDssegundoapellido.grabFocus();
                }
        }
       
         if ((txtDscelular == null || "".equals(txtDscelular.getText())) && (txtDstelefono == null || "".equals(txtDstelefono.getText())) && flag) {
            JOptionPane.showMessageDialog(this, "Debe ingresar un numero de teléfono o celular", "Validación", JOptionPane.WARNING_MESSAGE);
            flag = false;
            txtDscelular.grabFocus();
        }
    
        if (this.comboMgrDepartamento.getSelectedItem() == null && flag) {
            JOptionPane.showMessageDialog(this, "El departamento es obligatoria", "Validación", JOptionPane.WARNING_MESSAGE);
    
        }
       if (this.comboMgrCiudad.getSelectedItem() == null && flag) {        flag = false;
            JOptionPane.showMessageDialog(this, "La ciudad es obligatoria", "Validación", JOptionPane.WARNING_MESSAGE);
            flag = false;
        }
        
        
      return flag;
    }

    @Override
    public void cancelarProceso() {
         int message = JOptionPane.showConfirmDialog(this, "Está seguro que desea salir?", "Salir", JOptionPane.YES_NO_OPTION);
        if (message == JOptionPane.YES_OPTION) {
            HawkViewMgr.getInstance().removeObjectInstance(this.getClass());
            System.gc();
            this.dispose();
        }
    }

    @Override
    public void cargarDatosMaestros() {
        
         MaestrosDTO maestro = new MaestrosDTO();
        DatosMaestrosDTO filtro = new DatosMaestrosDTO();

        maestro.setComaestro(HawkConstantes.Maestros.TIPO_DOCUMENTO.getCodigoMestro());
        filtro.setScmaestro(maestro);
        try {
            controllerDatosMaestros.cargarDatosMaestros(new Utility.CallBackSmartHawk <List<DatosMaestrosDTO>>() {

                @Override
                public void endProcess(List<DatosMaestrosDTO> object) {
                    /**
                     * cargar Marcas
                     */
                   comboMgrTipoDocumento = new HawkComboBoxMgr<>(cbTipoDocumento);
                    comboMgrTipoDocumento.setEmptyValue(null);
                    comboMgrTipoDocumento.setData(object);
                }
            }, filtro);
        } catch (Throwable thr) {
            JOptionPane.showMessageDialog(this, "Error cargando datos :\n" + thr.getMessage(), "Error carga inicial", JOptionPane.ERROR_MESSAGE);
        }
    }

    @Override
    public void initComponentsTerceros() {
        jpJuridico.setVisible(false);
        jdFechaNacimiento.getDateEditor().setEnabled(false);
        cargarDatosMaestros(); 
        listarDepartamentos();
    }

    @Override
    public void listarDepartamentos() {
        PaisDTO paisDTO = new PaisDTO();
        DepartamentoDTO departamentoDTO = new DepartamentoDTO(); 
        
        paisDTO.setCopais(HawkConstantes.Maestros.PAIS_COL.getCodigoMestro());
        departamentoDTO.setPais(paisDTO);
        
        try{
            controllerDepartamentos.listarDepartamentos(new Utility.CallBackSmartHawk<List<DepartamentoDTO>>() {

                @Override
                public void endProcess(List<DepartamentoDTO> object) {
                    /**
                     * cargar departamentos
                     */
                    comboMgrDepartamento = new HawkComboBoxMgr<>(cbDepartamento);
                    comboMgrDepartamento.setEmptyValue(null);
                    comboMgrDepartamento.setData(object);
                }
            }, departamentoDTO);
        }catch(Throwable thr) {
            JOptionPane.showMessageDialog(this, "Error cargando los departamentos :\n" + thr.getMessage(), "Error carga inicial", JOptionPane.ERROR_MESSAGE);
        }        
    }

    @Override
    public void listarCiudades() {
        DepartamentoDTO departamentoDTO = new DepartamentoDTO(); 
        CiudadDTO ciudadDTO = new CiudadDTO();
        
        try{
            comboMgrCiudad = new HawkComboBoxMgr<>(cbCiudad);
            comboMgrCiudad.setEmptyValue(null);
            comboMgrCiudad.setData(null);
            if(this.comboMgrDepartamento.getSelectedItem() != null){   
                departamentoDTO = comboMgrDepartamento.getSelectedItem();
                ciudadDTO.setDepartamento(departamentoDTO);
                
                controllerCiudades.listarCiudades(new Utility.CallBackSmartHawk<List<CiudadDTO>>() {
                    @Override
                    public void endProcess(List<CiudadDTO> object) {
                                                /**
                        * cargar departamentos
                        */
                        comboMgrCiudad = new HawkComboBoxMgr<>(cbCiudad);
                        comboMgrCiudad.setEmptyValue(null);
                        comboMgrCiudad.setData(object);
                    }
                }, ciudadDTO);
            }
        }catch(Throwable thr){
            JOptionPane.showMessageDialog(this, "Error cargando las ciudades :\n" + thr.getMessage(), "Error carga inicial", JOptionPane.ERROR_MESSAGE);
        }
    
    }

    @Override
    public void limpiarFormulario() {
        
           comboMgrTipoDocumento.refresh();
            txtcoidentificacion.setText("");
            txtDsprimernombre.setText("");
            txtDssegundonombre.setText("");
            txtDsprimerapellido.setText("");
            txtDssegundoapellido.setText("");
            txtDsrazonsocial.setText("");
            txtDsnombrecontacto.setText("");
            txtDscelular.setText("");
            txtDsdireccion.setText("");
            txtDstelefono.setText("");
            txtDsemail.setText("");
            txtDsextension.setText("");
            comboMgrDepartamento.refresh();
            comboMgrCiudad = new HawkComboBoxMgr<>(cbCiudad);
            comboMgrCiudad.setEmptyValue(null);
            comboMgrCiudad.setData(null);
            txtDsemail.setText("");
            jdFechaNacimiento.setDate(null);
           
    }
    
    public void ocultarcomponente() {
      //  
       if (this.comboMgrTipoDocumento.getSelectedItem()!= null){
           DatosMaestrosDTO tipodocumento = new DatosMaestrosDTO();
           tipodocumento = comboMgrTipoDocumento.getSelectedItem();
          
           if(tipodocumento.getCodatmaestro().equals(HawkConstantes.Maestros.NIT.getCodigoMestro())){
               jpNatural.setVisible(false);
               jpJuridico.setVisible(true);
            }else {
               jpNatural.setVisible(true);
               jpJuridico.setVisible(false);
           } 
       }else {
               jpNatural.setVisible(true);
               jpJuridico.setVisible(false);
               
               
               
               
               
               
               
       } 
    }

    @Override
    public void consultarterceros() {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    
             
 

  
}
